﻿namespace WMS6.SQLServerDAL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.DBUtility;
    using WMS6.IDAL;
    using WMS6.QueryEntity;

    public class RotationRuleDetailDA : IRotationRuleDetailDA
    {
        private string CREATED_BY = "@CREATED_BY";
        private string DESCR = "@DESCR";
        private string IS_ACTIVE = "@IS_ACTIVE";
        private string LINE_ID = "@LINE_ID";
        private string LOT_ATTRIBUTES = "@LOT_ATTRIBUTES";
        private string LOTATTRIBUTES = "@LOTATTRIBUTES";
        private string ROTATION = "@ROTATION";
        private string ROTATION_RULE_ID = "@ROTATION_RULE_ID";
        private string SQL_CHECK_ROTATION_RULE_DETAIL_ID_UNIQUE = " SELECT COUNT(1) FROM @_@ROTATION_RULE_DETAIL WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID AND LOT_ATTRIBUTES = @LOTATTRIBUTES ";
        private string SQL_DELETE_ROTATION_RULE_DETAIL = " DELETE FROM @_@ROTATION_RULE_DETAIL WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID AND LOT_ATTRIBUTES = @LOTATTRIBUTES";
        private string SQL_INSERT_ROTATION_RULE_DETAIL = " INSERT INTO @_@ROTATION_RULE_DETAIL ( WH_ID, ROTATION_RULE_ID, LOT_ATTRIBUTES, LINE_ID, DESCR, ROTATION, IS_ACTIVE, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @ROTATION_RULE_ID, @LOT_ATTRIBUTES, @LINE_ID, @DESCR, @ROTATION, @IS_ACTIVE, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_SELECT_ALL_ROTATION_RULE_DETAIL = " SELECT  ROWID, WH_ID, ROTATION_RULE_ID, LOT_ATTRIBUTES, LINE_ID, DESCR, ROTATION, IS_ACTIVE, TS, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE  FROM  @_@ROTATION_RULE_DETAIL ";
        private string SQL_UPDATE_ROTATION_RULE_DETAIL = " UPDATE @_@ROTATION_RULE_DETAIL SET WH_ID = @WH_ID, LINE_ID = @LINE_ID, DESCR = @DESCR, ROTATION = @ROTATION, IS_ACTIVE = @IS_ACTIVE, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID AND LOT_ATTRIBUTES = @LOT_ATTRIBUTES  ";
        private string TS = "@TS";
        private string UPDATED_BY = "@UPDATED_BY";
        private string WH_ID = "@WH_ID";

        public bool CheckRotationRuleDetailIDUnique(string rotationRuleDetailID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleDetailID) };
            return (DBHelper.ExecuteScalar(CommandType.Text, this.SQL_CHECK_ROTATION_RULE_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public bool CheckRotationRuleDetailIDUnique(string rotationRuleID, string lotAttributes, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleID), new SqlParameter("@LOTATTRIBUTES", lotAttributes) };
            return (DBHelper.ExecuteScalar(CommandType.Text, this.SQL_CHECK_ROTATION_RULE_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public bool CheckRotationRuleDetailIDUnique(DataBase dataBase, DbTransaction tran, string rotationRuleDetailID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleDetailID) };
            return (dataBase.ExecuteScalar(tran, CommandType.Text, this.SQL_CHECK_ROTATION_RULE_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public bool CheckRotationRuleDetailIDUnique(DataBase dataBase, DbTransaction tran, string rotationRuleID, string lotAttributes, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleID), new SqlParameter("@LOTATTRIBUTES", lotAttributes) };
            return (dataBase.ExecuteScalar(tran, CommandType.Text, this.SQL_CHECK_ROTATION_RULE_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public int DeleteRotationRuleDetail(List<string> rotationRuleDetailID, List<string> whLoginID)
        {
            int result = 0;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            string StrSql = "DELETE FROM @_@ROTATION_RULE_DETAIL WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID ";
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < rotationRuleDetailID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleDetailID[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, StrSql.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int DeleteRotationRuleDetail(List<string> rotationRuleID, List<string> lotAttributes, List<string> whLoginID)
        {
            int result = 0;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < rotationRuleID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleID[j]), new SqlParameter("@LOTATTRIBUTES", lotAttributes) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int DeleteRotationRuleDetail(DataBase dataBase, DbTransaction tran, List<string> rotationRuleDetailID, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                string StrSql = "DELETE FROM @_@ROTATION_RULE_DETAIL WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID ";
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < rotationRuleDetailID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleDetailID[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, StrSql.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int DeleteRotationRuleDetail(DataBase dataBase, DbTransaction tran, List<string> rotationRuleID, List<string> lotAttributes, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    for (int j = 0; j < rotationRuleID.Count; j++)
                    {
                        SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleID[j]), new SqlParameter("@LOTATTRIBUTES", lotAttributes[j]) };
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public DataSet GetAllRotationRuleDetail(string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID);
            return DBHelper.ExecuteDataSet(CommandType.Text, sql);
        }

        public DataSet GetAllRotationRuleDetail(DataBase dataBase, DbTransaction tran, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID);
            return dataBase.ExecuteDataSet(tran, CommandType.Text, sql);
        }

        public RotationRuleDetailInfo GetRotationRuleDetailByID(string rotationRuleID, string lotAttributes, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID) + " WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID AND LOT_ATTRIBUTES = @LOT_ATTRIBUTES ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleID), new SqlParameter("@LOT_ATTRIBUTES", lotAttributes) };
            RotationRuleDetailInfo rotationRuleDetailInfo = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                if (reader.Read())
                {
                    rotationRuleDetailInfo = new RotationRuleDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ROTATION_RULE_ID"].ToString(), reader["LOT_ATTRIBUTES"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["DESCR"].ToString(), reader["ROTATION"].ToString(), reader["IS_ACTIVE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : new DateTime(), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
                }
            }
            return rotationRuleDetailInfo;
        }

        public RotationRuleDetailInfo GetRotationRuleDetailByID(DataBase dataBase, DbTransaction tran, string rotationRuleID, string lotAttributes, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID) + " WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID AND LOT_ATTRIBUTES = @LOT_ATTRIBUTES  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleID), new SqlParameter("@LOT_ATTRIBUTES", lotAttributes) };
            RotationRuleDetailInfo rotationRuleDetailInfo = null;
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            if (reader.Read())
            {
                rotationRuleDetailInfo = new RotationRuleDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ROTATION_RULE_ID"].ToString(), reader["LOT_ATTRIBUTES"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["DESCR"].ToString(), reader["ROTATION"].ToString(), reader["IS_ACTIVE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : new DateTime(), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return rotationRuleDetailInfo;
        }

        public DataSet GetRotationRuleDetailByQueryList(List<string> sqlWhere, RotationRuleDetailQueryEntity rotationruledetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!rotationruledetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, rotationruledetailQuery.CurrentPage, rotationruledetailQuery.PageSize, rotationruledetailQuery.SortField, rotationruledetailQuery.SortDirection);
            }
            return DBHelper.ExecuteDataSet(CommandType.Text, temp);
        }

        public DataSet GetRotationRuleDetailByQueryList(DataBase dataBase, DbTransaction tran, List<string> sqlWhere, RotationRuleDetailQueryEntity rotationruledetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!rotationruledetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, rotationruledetailQuery.CurrentPage, rotationruledetailQuery.PageSize, rotationruledetailQuery.SortField, rotationruledetailQuery.SortDirection);
            }
            return dataBase.ExecuteDataSet(tran, CommandType.Text, temp);
        }

        public List<RotationRuleDetailInfo> GetRotationRuleDetailListByID(string rotationRuleID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID) + " WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleID) };
            List<RotationRuleDetailInfo> rotationRuleDetailList = new List<RotationRuleDetailInfo>();
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                RotationRuleDetailInfo rotationRuleDetailInfo = null;
                while (reader.Read())
                {
                    DateTime CS00002;
                    rotationRuleDetailInfo = new RotationRuleDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ROTATION_RULE_ID"].ToString(), reader["LOT_ATTRIBUTES"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["DESCR"].ToString(), reader["ROTATION"].ToString(), reader["IS_ACTIVE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()));
                    rotationRuleDetailList.Add(rotationRuleDetailInfo);
                }
            }
            return rotationRuleDetailList;
        }

        public List<RotationRuleDetailInfo> GetRotationRuleDetailListByID(DataBase dataBase, DbTransaction tran, string rotationRuleID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID) + " WHERE ROTATION_RULE_ID = @ROTATION_RULE_ID ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ROTATION_RULE_ID", rotationRuleID) };
            List<RotationRuleDetailInfo> rotationRuleDetailList = new List<RotationRuleDetailInfo>();
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            RotationRuleDetailInfo rotationRuleDetailInfo = null;
            while (reader.Read())
            {
                DateTime CS00002;
                rotationRuleDetailInfo = new RotationRuleDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ROTATION_RULE_ID"].ToString(), reader["LOT_ATTRIBUTES"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["DESCR"].ToString(), reader["ROTATION"].ToString(), reader["IS_ACTIVE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()));
                rotationRuleDetailList.Add(rotationRuleDetailInfo);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return rotationRuleDetailList;
        }

        public int InsertRotationRuleDetail(RotationRuleDetailInfo rotationRuleDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    rotationRuleDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_RotationRuleDetail_Parameters(rotationRuleDetailInfo);
                    if (paras != null)
                    {
                        result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int InsertRotationRuleDetail(DataBase dataBase, DbTransaction tran, RotationRuleDetailInfo rotationRuleDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    rotationRuleDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_RotationRuleDetail_Parameters(rotationRuleDetailInfo);
                    if (paras != null)
                    {
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        private SqlParameter[] Set_RotationRuleDetail_Parameters(RotationRuleDetailInfo rotationRuleDetailInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.ROTATION_RULE_ID, SqlDbType.VarChar, 20), new SqlParameter(this.LOT_ATTRIBUTES, SqlDbType.VarChar, 20), new SqlParameter(this.LINE_ID, SqlDbType.Int, 4), new SqlParameter(this.DESCR, SqlDbType.VarChar, 100), new SqlParameter(this.ROTATION, SqlDbType.VarChar, 20), new SqlParameter(this.IS_ACTIVE, SqlDbType.VarChar, 1), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 20), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 20) };
            if (!string.IsNullOrEmpty(rotationRuleDetailInfo.WhID))
            {
                paramArray[0].Value = rotationRuleDetailInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = rotationRuleDetailInfo.RotationRuleID;
            paramArray[2].Value = rotationRuleDetailInfo.LotAttributes;
            paramArray[3].Value = rotationRuleDetailInfo.LineID;
            paramArray[4].Value = rotationRuleDetailInfo.Descr;
            if (!string.IsNullOrEmpty(rotationRuleDetailInfo.Rotation))
            {
                paramArray[5].Value = rotationRuleDetailInfo.Rotation;
            }
            else
            {
                paramArray[5].Value = DBNull.Value;
            }
            paramArray[6].Value = rotationRuleDetailInfo.IsActive;
            paramArray[7].Value = rotationRuleDetailInfo.CreatedBy;
            paramArray[8].Value = rotationRuleDetailInfo.UpdatedBy;
            return paramArray;
        }

        public int UpdateRotationRuleDetail(RotationRuleDetailInfo rotationRuleDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    rotationRuleDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_RotationRuleDetail_Parameters(rotationRuleDetailInfo);
                    if (paras != null)
                    {
                        result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int UpdateRotationRuleDetail(DataBase dataBase, DbTransaction tran, RotationRuleDetailInfo rotationRuleDetailInfo, List<string> whLoginID)
        {
            int result = 0;
            try
            {
                for (int i = 0; i < whLoginID.Count; i++)
                {
                    rotationRuleDetailInfo.WhID = whLoginID[i].Substring(0, whLoginID[i].Length - 1);
                    SqlParameter[] paras = this.Set_RotationRuleDetail_Parameters(rotationRuleDetailInfo);
                    if (paras != null)
                    {
                        result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_ROTATION_RULE_DETAIL.Replace("@_@", whLoginID[i]), paras);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }
    }
}

